/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * \file
 * \brief Datatypes for a SQL interface.
 * \author Antti Maula <antti.maula@tkk.fi>
 *
 * $Id: SQLTypes.hpp,v 1.5 2009-08-05 06:09:00 amaula Exp $
 *
 */
#ifndef _MACI_SQLTYPES_HPP_
#define _MACI_SQLTYPES_HPP_
#include <inttypes.h>
#include "ownutils.h"
#include "owndebug.h"
#include "common/text.hpp"

namespace MaCI {

  /** MaCI - SQL interface.
   *
   * This namespace contains all the methods and types related
   * to the SQL interface.
   *
   * \note This interface is still under heavy developement. Please
   * consider this interface to be on Alpha stage of testing before
   * this note is removed!
   */
  namespace SQL {
    
    /** Enumeration types for SQL data elements.
     */
    enum ESQLType { 
      KTypeUnknown               = -1, ///< Unkown type.
      KTypeTimestamp             = 1,  ///< Common::TTimestamp element.
      KTypeCommand               = 2,  ///< TCommand element.
      KTypeSQLResultXML       = 3,  ///< TSQLResultXML element.
      KTypeSQLQuery              = 4   ///< TSQLQuery element.
    };
    
    
    /** Enumerations for SQL Command.
     */
    enum ESQLCommand { 
      /** Execute SQL query. Request is packed in 'TSQLQuery'
       *  container, and 'data' field of command contains the
       *  transaction ID.
       */
      KCommandExecuteSQLQuery = 1,

      /** Reply to a previous SQL query. Data is packed in
       * 'TSQLResultXML', and 'data' field of this command
       * structure contains the request transaction ID.
       */
      KCommandSQLResult       = 2
    };


    /** SQL command.
     *
     * This structure contains command field to be used when sending
     * action requests to SQL enabled clients.
     *
     * \see ESQLCommand
     */
    struct TCommand 
    {
      TCommand(const unsigned int aCmd = 0,
               const unsigned int aData = 0) 
	: cmd(aCmd),
          data(aData) {}
      uint32_t cmd;             ///< Command
      uint32_t data;            ///< Data for command. (Is command specific)
    };


    /** Text container containing SQLResultXML data.
     */
    typedef Common::TText TSQLResultXML;

    
    /** Text container containing SQL Query.
     *
     * The underlying implementation of text container is the standard
     * Common::TText.
     * 
     * 
     */
    typedef Common::TText TSQLQuery;
  }
}

#endif
